﻿var laso = {
	'version': '1.0',
	'appName': 'vspApp',
	'metaTitle': 'VSP3.4 App页面应用',
	'moduleIndex': '',
	'basePath': '/vsp',
	'apiPath': 'api',
	 'batch' :'batch',
	'uploadPath': 'fileClient',
	'ftpUploadPath':'fileUpload',
	'fileImport': 'fileImport',
	'excelImport': 'excelImport',
	'fileServerPath': 'http://dev.cpsdna.org:7080/fileserver/',
	'downloadURL': 'http://www.cpsdna.com/applist.html',
	'logoURL': 'images/4SPro/logo.png',
	'fileAllowExt': ["jpg","gif","png"],
	//'dinaLinkPhone':'025-83222152'  , //dina 运维电话
	'role':{'admin':'VspAdminPro',            //集团管理员          laso.role.admin
			'deptAdmin':'VspDptAdminCXZPro',     //部门管理员          laso.role.deptAdmin
			'stAdmin':'VspStoreAdminPro',        //4S店管理员       laso.role.stAdmin
			'customAdmin':'Vsp4sPro',         //客服顾问              laso.role.customAdmin
			'amAdmin':'VspAMPro',             //售后顾问              laso.role.amAdmin
			'saleAdmin':'VspSalePro',         //销售顾问              laso.role.saleAdmin
			'wareRoomAdmin':'VspWareroomPro'  //精品库管              laso.role.wareRoomAdmin
		}
};

console.log(laso);

function Cmd(cmd, params) {
	this.cmd = cmd;
	this.params = params;
};

function toPercent(number,min){
	min =0.10;
	var  num = parseFloat(number,10);
	if(!laso.isEmpty(min)&&(num<=min&&num>0)){
		//return  min+'%';
		return  (Math.round(min * 10000)/100).toFixed(2) + '%';
	}
	return   (Math.round(num * 10000)/100).toFixed(2) + '%';
}

/**
 * @laso基础组件封装
 * @author fancy fancy@cpsdna.com 2013-03-26
 */
(function() {
	laso.nameSpace = function(str) {
		var arr = str.split('.');
        var o = laso;
		for (var i = 0; i < arr.length; i++) {
            o[arr[i]] = o[arr[i]] || {};
            o = o[arr[i]];
		}
	};

    laso.getModule = function(str) {
		var arr = str.split('.');
		for (var i = 0; i < arr.length; i++) {
			if (laso['module'][arr[i]] != undefined) {
                return laso['module'][arr[i]];
			}
		}
        return null;
    };
    

    
	/**
	 * @jquery ajax响应数据过滤器
	 * @超时过滤器
	 */
	laso.dataFilter =function (data ,type){
		if(data.result == 25 || data.result == 10){
			laso.genNoty("warning",data.resultNote);
			laso.module.user.checkUserIsLogin(data.result);
		}
		
		return data;
	};
	//var ajax = ic.ajax;
	
	laso.ajaxRequest = function(cmdName, params, callBack) {
		if(typeof params.operUserId == "undefined"){
			params.operUserId = laso.curUserId;
		}
		var jsonString = JSON.stringify(new Cmd(cmdName, params));
		jsonString=jsonString.replace(new RegExp("null","gm"),"");
		$.ajax({
			url: laso.basePath+"/"+laso.apiPath,  //+';JSESSIONID='+$.cookie('JSESSIONID')
			timeout: 30000,
			type: "POST",
			dataType: "json",
			contentType: "application/x-www-form-urlencoded",
			data: jsonString,
			//dataFilter: laso.dataFilter,
			success: callBack
		});
	};

	laso.ajaxSyncRequest = function(cmdName, parment, callBack) {
		if(typeof parment.operUserId == "undefined"){
			parment.operUserId = laso.curUserId;
		}
		var jsonString = JSON.stringify(new Cmd(cmdName, parment));
		jsonString=jsonString.replace(new RegExp("null","gm"),"");
		
		$.ajax({
			url: laso.basePath+"/"+laso.apiPath,
			timeout: 10000,
			type: "POST",
			dataType: "json",
			contentType: "application/x-www-form-urlencoded",
			data: jsonString,
			async: false,
			//dataFilter: laso.dataFilter,
			success: callBack
		});
		
	};
	/**
	 * @获取URL传入的key
	 */
	laso.getUrlParamByKey = function(key,parseStr) {
		var reg = new RegExp("(^|&|[?])"+key+"=([^&]*)(&|$)"); // 构造一个含有目标参数的正则表达式对象
		var  r = null ;
		
		if(!laso.isEmpty(parseStr)){
			r = parseStr.match(reg);
		}else{
			r = window.location.href.match(reg); // 匹配目标参数
		}

		if (r != null)
			return unescape(r[2]);
		return null; // 返回参数值

	};
	/**
	 * @处理pk数据
	 * @compareFlag  true  > 获胜       false  <  获胜
	 */
    laso.processPkData=function(dataNode,isDivideBy100,winobj,min,unit,noPkContent,compareFlag){
    	 var  scorePecent='width:0%' ;
		  var  pkScorePecent='width:0%' ;
		  var  scoreFlag ='display:none' ;
		  var  pkScoreFlag ='display:none';
		  var  compFlag = compareFlag;
		
		if(dataNode.pkFlag=='1'){ //pkFlag  0:不参加PK  1:参加pk
			
			if(isDivideBy100){
				scorePecent ='width:'+toPercent(dataNode.score/100,min);
				pkScorePecent = 'width:'+toPercent(dataNode.pkScore/100,min);
			}else{
				scorePecent =(dataNode.score+dataNode.pkScore)-0<=0?scorePecent: 'width:'+toPercent(dataNode.score/(dataNode.score+dataNode.pkScore),min);
				pkScorePecent=(dataNode.score+dataNode.pkScore)-0<=0?pkScorePecent: 'width:'+toPercent(dataNode.pkScore/(dataNode.score+dataNode.pkScore),min);
			}
		    if(compFlag){
		    	if(dataNode.score>dataNode.pkScore){
					 scoreFlag ='display:inline-block';
					 pkScoreFlag ='display:none';
					 winobj['myWinCount']++;
				}else if(dataNode.score==dataNode.pkScore){
					 scoreFlag ='display:none';
					 pkScoreFlag ='display:none';
				}else{
					 scoreFlag ='display:none';
					 pkScoreFlag ='display:inline-block';
					 winobj['pkWinCount']++;
				}
		    }else{
		    	if(dataNode.score<dataNode.pkScore){
					 scoreFlag ='display:inline-block';
					 pkScoreFlag ='display:none';
					 winobj['myWinCount']++;
				}else if(dataNode.score==dataNode.pkScore){
					 scoreFlag ='display:none';
					 pkScoreFlag ='display:none';
				}else{
					 scoreFlag ='display:none';
					 pkScoreFlag ='display:inline-block';
					 winobj['pkWinCount']++;
				}
		    }
			
			
			dataNode.scorePecent=scorePecent;
			dataNode.pkScorePecent=pkScorePecent;
			dataNode.scoreFlag =scoreFlag;
			dataNode.pkScoreFlag=pkScoreFlag;
			dataNode.scoreDesc=dataNode.score+unit;
			dataNode.pkScoreDesc=dataNode.pkScore+unit;
			
		}else{ //不参加PK
			
			dataNode.scoreDesc =noPkContent ;
			dataNode.pkScoreDesc =noPkContent;
			
		}
		dataNode.pkFlag=dataNode.pkFlag=='1'?true:false;  
    	
    	
    	
    };
	
	laso.isEmpty = function(str) {
		if (str == undefined || str == "" || str == null) {
			return true;
		}
		return false;
	};

	laso.alert = function(message, title, callback) {
		jAlert(message, title, callback);
	};

	laso.confirm = function(message, title, callback) {
		jConfirm(message, title, callback);
	};

	laso.prompt = function(message, value, title, callback) {
		jPrompt(message, value, title, callback);
	};

    laso.toogleTextWithInput = function(obj) {
        if ($.trim($(obj) .val()) == "未设置"){
            $(obj).val("");
        }
    };

    laso.toogleTextWithTextarea = function(obj) {
        if ($.trim($(obj) .val()) == "未设置"){
            $(obj).val("");
        }
    };
    
  //针对不支持indexOf方法不存在提供兼容
	laso.prototypeIndexOf = function(){
		if (!Array.prototype.indexOf)
		{
		  Array.prototype.indexOf = function(elt /*, from*/)
		  {
		    var len = this.length >>> 0;
		    var from = Number(arguments[1]) || 0;
		    from = (from < 0)
		         ? Math.ceil(from)
		         : Math.floor(from);
		    if (from < 0)
		      from += len;
		    for (; from < len; from++)
		    {
		      if (from in this &&
		          this[from] === elt)
		        return from;
		    }
		    return -1;
		  };
		}
	};
	
    /**
     * 生成noty提示
     * @param {string} type 可选值有 infomation warning error success
     * @param {string} text
     * @param {string} layout 类似topCenter
     * top: 顶部,长条状
	   topLeft/topCenter/topRight: 顶部的左/中/右位置, 短条状
	   center/centerLeft/centerRight: 正中/中左/中右, 短条状
	   bottomLeft/bottomCenter/bottomRight: 底部左/中/右位置, 短条状
	   bottom: 底部,长条状
     * 
     */
    laso.genNoty = function(type, text, layout,callback){
    	var title = '';
    	switch(type){
    	case 'success':
    		title = '成功';
    		break;
    	case 'error':
    		title = '错误';
    		break;
    	case 'warning':
    		title = '警告';
    		break;
    	default:
    		title = '';
    	}
        var n = noty({
            text        : '<strong>'+title+'   </strong>'+text,
            type        : type,
            dismissQueue: true,
            timeout     : false,
            layout      : layout == null ? 'center' : layout,  //topCenter  center
            theme       : 'bootstrapTheme',
            closeWith   : ['button', 'click'],
            maxVisible  : 20,
            maxVisible: 1, // you can set max visible notification for dismissQueue true option,
            killer: true,
            callback:{
            	afterShow:callback
            }
        });
    };

    /**
     * 生成noty confirm提示
     * @param {string} type 可选值有 infomation warning error success
     * @param {string} text
     * @param {string} layout 类似topCenter
     */
    laso.genNotyConfirm = function(text, layout,callBack){
        var n = noty({
            text        : text,
            type        : "confirm",
            dismissQueue: true,
            buttons     : [
                             {addClass: 'btn btn-primary', text: '确认', onClick: function ($noty) {
//                            	 callBack();
//                            	 $noty.close();
                            	 $noty.close();
                            	 callBack();
                             }
                             },
                             {addClass: 'btn btn-danger', text: '取消', onClick: function ($noty) {
                                 $noty.close();}
                             }
                          ],
        
            timeout     : 2500,
            layout      : layout == null ? 'center' : layout, //center
            theme       : 'bootstrapTheme',
            closeWith   : ['button', 'click'],
            maxVisible  : 20,
            maxVisible: 1, // you can set max visible notification for dismissQueue true option,
            killer: true
        });
    };
	/**
	 * @param bandObj obj    绑定对象
	 * @param relId   string 图片相册ID
	 * @param srcArray   Array 图片数组
	 * @param titleArray Array 图片对应的标题数组
	 * @param widthS  int   缩略图宽度  默认 100  (px)
	 * @param heightS int   缩略图高度  默认 120  (px)
	 * 
	 */
	laso.fancybox=function(bandObj,relId,srcArray,titleArray,widthS,heightS){
		var  width = laso.isEmpty(widthS)?100:widthS;
		var  height = laso.isEmpty(heightS)?120:heightS;
		var  rel    =laso.isEmpty(relId)?"picGroup":relId;
		var  picHtml ="";
		for(var i=0;i<srcArray.length;i++){
			picHtml += '<a rel="'+rel+'" title="'+titleArray[i]+'" href="' + srcArray[i] + '">'
       				+ '<img class="photo" alt="" src="' + srcArray[i] + '"'+'width="'+width+'" height="'+height+'" /></a>' ;
		}
		
		bandObj.html(picHtml);
		//
		$("a[rel='"+rel+"']").fancybox({
			'transitionIn'		: 'none',
			'transitionOut'		: 'none',
			'titlePosition' 	: 'over',
			'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over" style="margin-bottom:15px;padding:6px 15px; background:#fff; color:#000; border-radius:4px; display:inline-block">照片 ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '   ' + title : '') + '</span>';
			}
		});	
		
	};
	/**
	 * @验证金额 两位小数
	 */
	laso.isMoney=function(money){
		 var regu = /^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/;
		    if (regu.test(money)) {
		        return true;
		    }
		    else {
		        return false;
		    }
		
	};
	/**
     * 验证非法字符
     * @param {string}
     * @return {boolean}, 返回false表示含有非法字符
     */
	laso.checkStrValid = function(checkStr) {
		if(typeof checkStr == "undefined"){
			return true;
		}
		var str = ["!", "#", "$", "%", "/", "\\", "'", "*", "&", "|","！","#","￥","%","、","、、","‘","*","&","|"];
		for (var i = 0; i < str.length; i++) {
			if (checkStr.indexOf(str[i]) >= 0) {
				return false;
			}
		}
		return true;
	};

	/**
     * 验证车牌号是否正确
     * @param {string}
     * @returns {boolean}
     */
	laso.isCarNo = function(str) {
		var no = $.trim(str);
		if (no == "") {
			return true;
		}
		var patrn = /^[(\u4e00-\u9fa5)|(a-zA-Z)]{1}[a-zA-Z]{1}[a-zA-Z_0-9]{4,6}[a-zA-Z_0-9_\u4e00-\u9fa5]$/;
		if (!patrn.exec(no)) {
			return false;
		}
		return true;
	};
	
	/**
	 * 验证Email是否正确
	 * 
	 * @param strEmail
	 * @returns {Boolean}
	 */
	laso.isEmail = function (strEmail) {
		var pattern = /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
		if (strEmail == ''){
			return true;
		}
		return pattern.test(strEmail);
	};
	/**
	 * 验证 0 或 正整数
	 */
	laso.isPositiveInteger = function(value){
		var re=/^(([1-9]{1}\d*)|([0]{1}))$/;
		return re.test(value);
	};
    
	/***
	 * 正整数验证
	 ***/
	laso.checkIntegerValid = function (checkStr){
		var reg = /^[0-9]*[1-9][0-9]*$/;
		return reg.test(checkStr);
	};
	
    /** 
     * 生成格式化的排量显示字符串
     * @param {string} str
     * @return {string}
     */ 
    laso.formatDisplacement = function(str) 
    {
        var reg =  /^([1-9]\d|\d).\dT$/ ;
        if (!reg.test(str)) {
            return str + "L";
        }
        return str;
    };

    /**
     * 判断日期区间的合法性，若提交间隔限制，可进行限制判断
     * @param {string} startTime
     * @param {string} endTime
     * @param {string} dateLimit
     * @returns {boolean}   
     */
    laso.checkPeriodDateValid = function(startTime,endTime,dateLimit) {
    	var startTimeArray = startTime.split("-");
    	var endTimeArray = endTime.split("-");
    	startTime = startTimeArray.join("/");
    	endTime = endTimeArray.join("/");
    	
    	var startDate = new Date(startTime);
    	var endDate = new Date(endTime);
    	
    	if (endDate.getTime() - startDate.getTime() < 0) {
    		laso.alert("结束时间不能小于开始时间", "提示");
    		return false;
    	}

    	if(typeof dateLimit != "undefined" ){
    		if ((endDate.getTime() - startDate.getTime() +1) / (24 * 60 * 60 * 1000) > dateLimit) {
        		laso.alert("查询时间段不能超过"+dateLimit+"天", "提示");
        		return false;
        	}
    	}
    	
    	
    	return true;
    };
    
    laso.checkPeriodDateValidV2 = function(startTime,endTime,dateLimit) {
    	var startTimeArray = startTime.split("-");
    	var endTimeArray = endTime.split("-");
    	startTime = startTimeArray.join("/");
    	endTime = endTimeArray.join("/");
    	
    	var startDate = new Date(startTime);
    	var endDate = new Date(endTime);
    	

    	if (endDate.getTime() - startDate.getTime() < 0) {
    		return false;
    	}
    	
    	if(typeof dateLimit != "undefined" ){
    		if ((endDate.getTime() - startDate.getTime() +1) / (24 * 60 * 60 * 1000) > dateLimit) {
        		return false;
        	}
    	}
    	
    	
    	return true;
    };
    
    /**
     * 比较日期大小
     * @param {string} startTime
     * @param {string} endTime
     * @returns {boolean}   
     */
    laso.compareDate = function(startTime,endTime) {
    	var startTimeArray = startTime.split("-");
    	var endTimeArray = endTime.split("-");
    	startTime = startTimeArray.join("/");
    	endTime = endTimeArray.join("/");
    	
    	var startDate = new Date(startTime);
    	var endDate = new Date(endTime);
    	
    	if (endDate.getTime() - startDate.getTime() < 0) {
    		return false;
    	}else{
    		return true;
    	}
    };
    
    /**
     * 获取指定日期距当前日期天数 （指定日期大于当前日期）
     * @param {string} startTime
     * @param {string} endTime
     * @returns {boolean}   
     */
    laso.getDaysFromToday = function(dateStr) {
    	var dateStrArray = dateStr.split("-");
    	dateStr = dateStrArray.join("/");
    	
    	var dateStrMilli = new Date(dateStr).getTime();
    	var todayMilli = new Date().getTime();
    	
    	return Math.floor((dateStrMilli-todayMilli)/(3600*1000*24));
    };
    
    /**
     * 获取指定日期
     * @param {string} date
     * @param {int} step
     * @returns {string}   
     */
    laso.getAssignDate = function(date,step) {
    	var dateArray = date.split("-");
    	dateTime = dateArray.join("/");
    	
    	var newDate = new Date(dateTime);
    	
    	//获取step天后的日期，若为负数，可获取过去的日期
    	newDate.setDate(newDate.getDate()+step);
    	
    	var y = newDate.getFullYear();
    	var m = newDate.getMonth()+1;//获取当前月份的日期
    	var d = newDate.getDate();
    	
    	if(parseInt(m) < 10){
    		 m = "0"+m;
    	}
    	
    	if(parseInt(d) < 10){
    		d = "0"+d;
    	}
    	
    	return y+"-"+m+"-"+d;
    };
    
    /**
     * 根据月份步长获取指定日期
     * @param {string} date
     * @param {int} step
     * @returns {string}   
     */
    laso.getAssignDateByMonth = function(date,step) {
    	var dateArray = date.split("-");
    	dateTime = dateArray.join("/");
    	
    	var newDate = new Date(dateTime);
    	
    	//获取step天后的日期，若为负数，可获取过去的日期
    	newDate.setMonth(newDate.getMonth()+step);
    	
    	var y = newDate.getFullYear();
    	var m = newDate.getMonth()+1;//获取当前月份的日期
    	var d = newDate.getDate();
    	
    	if(parseInt(m) < 10){
    		 m = "0"+m;
    	}
    	
    	if(parseInt(d) < 10){
    		d = "0"+d;
    	}
    	
    	return y+"-"+m+"-"+d;
    };
    
    /**
     * 获取今天日期
     * @returns {string}   
     */
    laso.getToday = function(){
    	var nowDate = new Date();
    	var y = nowDate.getFullYear();
    	var m = nowDate.getMonth()+1;
    	var d = nowDate.getDate();
    	
    	if(parseInt(m) < 10){
   		 	m = "0"+m;
    	}
   	
	   	if(parseInt(d) < 10){
	   		d = "0"+d;
	   	}
   	
	   	return y+"-"+m+"-"+d;
    };
    
    laso.getDateByDayStepUnderToday=function(step){
    	var nowDate = new Date();
    	nowDate.setDate(nowDate.getDate()+step)
    	var y = nowDate.getFullYear();
    	var m = nowDate.getMonth()+1;
    	var d = nowDate.getDate();
    	
    	if(parseInt(m) < 10){
   		 	m = "0"+m;
    	}
   	
	   	if(parseInt(d) < 10){
	   		d = "0"+d;
	   	}
   	
	   	return y+"-"+m+"-"+d;
    	
    }
    
    /**
     * 获取时间数组
     * @returns {Array}
     */
    laso.getTimeArray = function(time) {
    	var timeArray = time.split(" ");
    	var dateArray = timeArray[0].split("-");
    	var hmsArray = timeArray[1].split(":");
    	var detailArray = [];
    	
    	detailArray["year"] = dateArray[0];
    	detailArray["month"] = dateArray[1];
    	detailArray["day"] = dateArray[2];
    	detailArray["hour"] = hmsArray[0];
    	detailArray["minutes"] = hmsArray[1];
    	detailArray["seconds"] = hmsArray[2];
    	
    	return detailArray;
    	
    };
    
    /**
     * 检查是否未定义，如未定义则返回空
     * @param {string} obj
     * @returns {string}   
     */
    laso.checkUndefined = function (obj){
    	return (typeof obj == "undefined" ? "" : obj);
    };
    
    /**
     * 回车搜索函数
     * @param {string} selectStr
     * @param {string} callback
     * @returns {void}   
     */
    laso.enterSubmit = function (selectStr, callBack){
    	$(selectStr).bind('keyup',function(e){
    		if(e.keyCode == 13){
    			callBack();
    			return false;
    		}
    	 });
    };
    
    /**
     * @验证手机号是否正确
     * @param {String} str
     * @returns {Boolean}
     */
    laso.isMobel = function (str) {
    	if ($.trim(str) == '')
    		return;
    	var myreg = /^((\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$)$/;// ^((\+86)|(86))?(1)\d{10}$/;
    	if (!myreg.test(str)) {
    		return false;
    	} else {
    		return true;
    	}
    };
    
    /**
     * @验证电话号码
     * @param {String} checkStr
     * @returns {Boolean}
     */
    laso.checkLinkPhoneValid = function(checkStr){
    	var tel=/^(\(\d{3,4}\)|\d{3,4}\-{0,1})?\d{7,8}(\-\d{1,5})?$/;
    	var mobile = /^1[3|4|5|8][0-9]\d{4,8}$/;
    	
    	var test1 = tel.test(checkStr);
    	var test2 = mobile.test(checkStr);

    	return (test1 || test2);
    };
    
    /**
    * 电话验证(包含400及95555等特殊电话号码)
    * @param String checkStr
    * @return Boolean
    * @author fancy
    */
    laso.checkPhoneValid = function(checkStr) {
        var reg = /^(\d{3,4}\-?\d{7,8}|1\d{10}|9\d{4}|\d{3}\-?\d{3}\-?\d{4})$/;
        if(reg.test(checkStr))
        {
            return true;
        }
        return false;
    };
    
    /****
     * @验证仪表盘里程行驶为正确
     * @param String checkVal
     * @return Boolean
     * @author wangbin
     ****/
    laso.checkDistanceTotalValid = function (checkVal){
        var reg = /^([1-9][0-9]*|0)(\.\d+)?$/;
        var checkStr = checkVal.toString();
    	var test1 = reg.test(checkStr);
    	if(!test1) {
    		laso.genNoty("warning","仪表盘里程只能为正数");
    		return false;
    	}
    	
    	var checkStrArray = checkStr.split(".");
    	if(checkStrArray.length == 2){
    		if(checkStrArray[1].length > 1){
    			laso.genNoty("warning","仪表盘里程格式不对,最多保留1位小数");
    			return false;
    		}
    		
    		if(checkStrArray[0].length > 7){
    			laso.genNoty("warning","仪表盘里程格式不对,小数点前数字请控制在7位以内");
    			return false;
    		}
    	}else{
    		if(checkStrArray[0].length > 7){
    			laso.genNoty("warning","仪表盘里程格式不对,小数点前数字请控制在7位以内");
    			return false;
    		}
    	}
    	
    	return true;
    };
    
    /****
     * @验证里程正确
     * @param String checkVal
     * @return Boolean
     * @author wangbin
     ****/
    laso.checkMilesValid = function (checkVal,checkName){
        var reg = /^([1-9][0-9]*|0)(\.\d+)?$/;
        var checkStr = checkVal.toString();
    	var test1 = reg.test(checkStr);
    	if(!test1) {
    		laso.genNoty("warning",checkName+"只能为正数");
    		return false;
    	}
    	
    	var checkStrArray = checkStr.split(".");
    	if(checkStrArray.length == 2){
    		if(checkStrArray[1].length > 1){
    			laso.genNoty("warning",checkName+"格式不对,最多保留1位小数");
    			return false;
    		}
    		
    		if(checkStrArray[0].length > 7){
    			laso.genNoty("warning",checkName+"格式不对,小数点前数字请控制在7位以内");
    			return false;
    		}
    	}else{
    		if(checkStrArray[0].length > 7){
    			laso.genNoty("warning",checkName+"格式不对,小数点前数字请控制在7位以内");
    			return false;
    		}
    	}
    	
    	return true;
    };
    
    /****
     * @汽车排量验证，只验证X.X格式排量为正确
     * @param {string} checkStr
     * @returns {BOOLEAN}
     * @author wangbin
     ****/
    laso.checkDisplacementValid = function(checkStr) {
        var reg = /^([1-9]\d|\d)(\.\d)?$/;
    	if(!reg.test(checkStr)){
    		return false;
    	}
    	
    	return true;
    };
    
    /****
     * @验证是否英文
     * @param {string} checkStr
     * @returns {BOOLEAN}
     * @author wangbin
     ****/
    laso.checkStrIsEn = function(checkStr) {
        var reg = /^[a-zA-Z]{1,32}$/;
    	if(!reg.test(checkStr)){
    		return false;
    	}
    	
    	return true;
    };
    
    /**
     * 克隆一个对象
     */
    laso.clone = function(obj){
    	var objClone;
        if (obj.constructor == Object){
            objClone = new obj.constructor(); 
        }else{
            objClone = new obj.constructor(obj.valueOf()); 
        }
        for(var key in obj){
            if ( objClone[key] != obj[key] ){ 
                if ( typeof(obj[key]) == 'object' ){ 
                    objClone[key] = laso.clone(obj[key]);
                }else{
                    objClone[key] = obj[key];
                }
            }
        }
        objClone.toString = obj.toString;
        objClone.valueOf = obj.valueOf;
        return objClone; 
    };
  
	/**
     * 数组去重
     * author: wengq
     * 
     */
    laso.arrUnique = function(arr){
    	var n = {},r=[]; //n为hash表，r为临时数组
    	for(var i = 0; i < arr.length; i++) //遍历当前数组
    	{
    		if (!n[arr[i]]) //如果hash表中没有当前项
    		{
    			n[arr[i]] = true; //存入hash表
    			r.push(arr[i]); //把当前数组的当前项push到临时数组里面
    		}
    	}
    	return r;
    };
    
    /**
     * 格式化日期
     */
    laso.dateFormat = function(date, fmt){
    	// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符， 
    	// 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字) 
    	// 例子： 
    	// laso.dateFormat(new Date(), "yyyy-MM-dd hh:mm:ss.S") ==> 2014-01-06 08:09:04.423 
    	// laso.dateFormat(new Date(), "yyyy/M/d") ==> 2014/1/6 
    	 var o = {
 	        "M+": date.getMonth() + 1, //月份 
 	        "d+": date.getDate(), //日 
 	        "h+": date.getHours(), //小时 
 	        "m+": date.getMinutes(), //分 
 	        "s+": date.getSeconds(), //秒 
 	        "q+": Math.floor((date.getMonth() + 3) / 3), //季度 
 	        "S": date.getMilliseconds() //毫秒 
 	    };
 	    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
 	    for (var k in o)
 	    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
 	    return fmt;
    };
  
    /**
     * @表格样式函数
     * @param {jqueryObj}
     */
    laso.dataTable = function(wrap){
    	var obj = null;
    	obj = wrap.dataTable({
    		"bJQueryUI": true,
    		"bSort": false,
    		"bFilter": false,
    		"bProcessing": false,
    		"bLengthChange": false,
    		"bPaginate": false,
    		"bInfo" : false,
    		"bAutoWidth":true,
    		"bDestroy": true
    	});
    	return obj;
    };
    
    /**
     * 初始化tip样式
     */
    laso.initTip = function (){
		$('.tip_north').tipsy({gravity: 's'});
		$('.tip_south').tipsy({gravity: 'n'});
		$('.tip_east').tipsy({gravity: 'e'});
		$('.tip_west').tipsy({gravity: 'w'});
	};
	


	
		/**
	 * @param {jqueryObj}
	 * @param  bandobj  绑定对象
	 * @len    下拉框长度
	 * @textunit   显示文本单位
	 * 
	 */
	laso.getSelection = function(bandobj,start,end,textunit) {
		var optionStr = '<option value="">-请选择-</option>';
		var s = parseInt(start);
		var e   = parseInt(end);
		for (var i = s; i <= e; i++) {
			optionStr += '<option value="' +i+ '">'
			+ i + textunit+'</option>';
		}
		bandobj.html(optionStr);
	};
	
	/**
	 * checkbox全选和取消全选操作
	 */
	laso.checkAll = function(wrap1, wrap2){
		$(document).on('click',wrap1,function(){
			if($(wrap1).length == $(wrap1 + ":checked").length){
				$(wrap2).attr("checked","checked");
			}else{
				$(wrap2).removeAttr("checked");
			}
		});
		$(document).on('click',wrap2,function(){
			if($(wrap2).length != 0 && $(wrap2).length == $(wrap2 + ":checked").length){
				$(wrap1).attr("checked","checked");
			}else{
				$(wrap1).removeAttr("checked");
			}
		});
	};
	
	//获取变速箱类型名称
	laso.getTransmissionTypeName = function(transmissionType){
		var transmissionTypeText = '';
		switch(transmissionType){
		case '0':
		case 0:
			transmissionTypeText = '自动（AT）';
			break;
		case '1':
		case 1:
			transmissionTypeText = '手动（MT）';
			break;
		case '2':
		case 2:
			transmissionTypeText = '无极变速（CVT）';
			break;
		case '3':
		case 3:
			transmissionTypeText = '双离合变速（DSG）';
			break;
		case '4':
		case 4:
			transmissionTypeText = '序列变速箱（AMT）';
			break;
		default:
			transmissionTypeText = '';
		}
		return transmissionTypeText;
	};
	
	//获取驱动类型名称
	laso.getDriveTypeName = function(driveType){
		var driveTypeName = '';
		switch(driveType){
		case '1':
		case 1:
			driveTypeName = '前轮驱动';
			break;
		case '2':
		case 2:
			driveTypeName = '后轮驱动';
			break;
		case '3':
		case 3:
			driveTypeName = '四轮驱动';
			break;
		default:
			driveTypeName = '';
		}
		return driveTypeName;
	};
	
	/**
	 * @初始化时间控件 该控件地址：lib/datepicker
	 * @param {jqueryObj}  widgetContainer 日期组件容器
	 * @param {jqueryObj}  dateInput 显示日期的input
	 * @param {jqueryObj}  dateFrom 开始日期隐藏域
	 * @param {jqueryObj}  dateTo 结束日期隐藏域
	 */
	laso.initDatePicker = function(widgetContainer, dateInput, dateFrom, dateTo){
		//日历显示开关
		var state = false;
		//日历控件点击技术器
		var calendarClick = 0;
		
		var now = new Date();
		
		widgetContainer.DatePicker({
			flat: true,
			format: 'Y-m-d',
			calendars: 3,
			date: "",
			mode: 'range',
			starts: 1,
			onChange: function(formated) {
				if(calendarClick == 0){
					calendarClick++;
				}else if(calendarClick == 1){
					dateFrom.val(formated[0]);
					dateTo.val(formated[1]);
					
					dateInput.val(formated[0] + " 至 " +formated[1]);
					
					dateInput.click();
					
				}
			},
			onRender: function(date) {
				return {
					disabled: (date.valueOf() > now.valueOf())
				};
			}
		});
		
		
		dateInput.on('click', function(event){
			widgetContainer.css({"top" : ($(this).offset().top+25) + "px","left" : $(this).offset().left + "px"});
			widgetContainer.stop().animate({height: state ? 0 : widgetContainer.find('div.datepicker').get(0).offsetHeight}, 500);
			state = !state;
			return false;
		});
	};
	
	/**
	 * @初始化图片上传
	 * @param {jqueryObj}  widgetContainer 图片上传组件容器
	 * @param {boolean}  autoGenerate 是否自动生成DOM结构
	 * @param {number}  count 自动生成的图片上传DOM结构个数，默认为1
	 */
	laso.initImageUpload = function(widgetContainer, autoGenerate, count){
		var optionsAdd = { 
				url : laso.ftpUploadPath,
				dataType: null,
			    success:    function(data) {
			    	
			    	$(blockCon).unblock();
			    	if(data == ""){
			    		laso.alert("图片上传被终止","失败");
			    		uploadBtn.show();
			    		uploadBtn.parent().find(".picAdd").val("");
			    		return false;
			    	}
			    	
			    	var jsonData = JSON.parse(data);
			    	if(jsonData.result != 0){
			    		laso.alert(jsonData.resultNote,"失败");
			    		uploadBtn.show();
			    		uploadBtn.parent().find(".picAdd").val("");
			    	}else{
			    		deleteBtn.show();
			    		deleteBtn.parent().find(".uploadAdd").hide();
			    		
			    		var path = jsonData.detail.path;
			    		$(blockCon).find('.uploadActive').removeClass('uploadActive');
			    		$(blockCon).find('.picUrlAdd').attr('src', path).show();
			    	}
			    },
			    error: function(){
			    	$(blockCon).unblock();
			    	uploadBtn.show();
			    	uploadBtn.parent().find(".picAdd").val("");
			    	laso.alert("上传失败");
			    }
			};
		
		if(autoGenerate){
			var picAreaLi = '<li class="picArea" style="height:auto !important">'
				        		+'<p class="picWrapper"><img class="picUrlAdd" src="" width="100" height="120"></p>'
				        		+'<div class="uploadBtnWrapper">'
				        		+	'<a class="whitishBtn button_small uploadBtn" href="javascript:void(0);">图片上传</a>'
				        		+	'<a class="whitishBtn button_small deleteBtn" href="javascript:void(0);" style="display:none;z-index:9999">图片删除</a>'
				        		+	'<div class="uploadAdd">'
				            	+		'<form method="post"  enctype="multipart/form-data">'
								+			'<input class="picAdd" name="file" type="file"/>'			
								+		'</form>'
								+	'</div>'
				        		+'</div>'
				        	+'</li>';
			var picAreaDom = '';
			if(count == null)
				count = 1;			
			for(var i=0; i<count; i++){
				picAreaDom += picAreaLi;
			}
			widgetContainer.append('<ul>'+ picAreaDom +'</ul>');
			
			$('body').append('<div id="processbarCon" style="display:none"><div id="progressbar"></div></div>');
		}
		
		
		widgetContainer.find('.picAdd').on('change', function(){
			var obj = $(this);
			var logoArray = $(this).val().split(".");
	 		if($.inArray(logoArray[logoArray.length-1].toLocaleLowerCase(),laso.fileAllowExt) == -1){
	 			laso.alert("只支持："+laso.fileAllowExt.join(",")+"格式的图片");
	 			return;
	 		}
	 		
	 		uploadBtn = $(this).closest('.uploadBtnWrapper').find(".uploadBtn");
			deleteBtn = $(this).closest('.uploadBtnWrapper').find(".deleteBtn");
			
			uploadBtn.hide();
	 		$(this).closest('.picArea').find('img').addClass('uploadActive');
	 		blockCon = $(this).closest('.picArea').find("p");
	 		
	 		
			//初始化进度条控件
			initProcessBar();
		
			blockCon.block({ 
		        fadeIn: 1000, 
		        fadeOut: 1000,
		        message: $("#processbarCon"),
		        overlayCSS: { 
		        	opacity: 0
		        },
		        css: { 
		            padding:        0, 
		            margin:         0,
		            width:          '60%', 
		            top:            '40%', 
		            left:           '35%', 
		            textAlign:      'center', 
		            color:          '#000', 
		            border:         '0px', 
		            backgroundColor:'#fff', 
		            cursor:         'wait' 
		        }, 
		        onBlock: function() {
			 		obj.parent().ajaxSubmit(optionsAdd);
			 		return false;
		        }
		    });
			
	        return false;
		});	 	
		
		//图片删除事件
		widgetContainer.find(".deleteBtn").on("click",function(){
			$(this).hide();
			$(this).parent().find(".uploadBtn").show();
			$(this).closest('.picArea').find('img').attr("src","").hide();
			$(this).parent().find(".picAdd").val("");
			$(this).parent().find(".uploadAdd").show();
		});
	};
	
	/**
	 * @重置图片上传到初始状态
	 * @param {jqueryObj}  widgetContainer 图片上传组件容器 默认为body
	 */
	laso.resetImageUpload = function(widgetContainer){
		if(widgetContainer == null){
			widgetContainer = $('body');
		}
		widgetContainer.find('.picUrlAdd').val('').hide();
		widgetContainer.find('.uploadBtn').show();
		widgetContainer.find('.deleteBtn').hide();
		widgetContainer.find('.uploadAdd').show();
		widgetContainer.find('.picAdd').val('');
	};
	
	/***初始化翻页控件********/
	laso.initBootstrapPaginator = function(pageId,selectId,pagesId,callFunc,data){
		var options = {
				bootstrapMajorVersion:2,
                currentPage: data.pageNo+1,
                totalPages: data.pages==0?1:data.pages,     // data.pages=>  data.pages==0?1:data.pages, 规避saas查询不到数据该参数返回0  导致报错
                size:'normal',
                alignment:'right',
                useBootstrapTooltip:false,
                onPageClicked:function(event, originalEvent, type,page){
                	callFunc(page-1);
                	event.stopImmediatePropagation();
                }
            };

       $('#'+pageId).bootstrapPaginator(options);
       
       if(data.totalRecordNum == 0){
    	   $("#"+pagesId).hide();
       }else{
    	   $("#"+pagesId).show();
    	   $("#"+pagesId).html("共"+data.totalRecordNum+"条数据");
       }
      
       if(data.pages <=1 || typeof data.pages == "undefined"){
    	   $("#"+selectId).hide();
       }else{
    	   var content = "";
    	   for(var i=0; i<data.pages;i++){
    		   content += "<option value='"+(i+1)+"'>"+(i+1)+"</option>";
    	   }
    	   $("#" + selectId).show();  //否则 先查询不到结果  在查询到结果  该组件就会被隐藏
    	   $("#"+selectId).html(content).val(data.pageNo+1);
    	   $("#"+selectId).unbind().on("change",function(){
        	   callFunc($(this).val()-1);
           });
       }
      
	};
	/**
	 * @等待组件
	 * @message ：显示的等待信息       默认值为：请稍后...
	 * @zIndex ： 层数，确保 该组件显示在最上层 默认值：1300
	 */
	laso.blockUI=function(message,zIndex){
		var msg = laso.isEmpty(message)?"请稍后...":message ;
		var partten = /^\+?[1-9][0-9]*$/;
		var index = partten.test(zIndex) == true ? zIndex : 1300;
		
		$.blockUI({
				fadeIn: 1000, 
				fadeOut: 1000,
				message: '<img src="../车行者_files/images/process.gif" style="vertical-align:middle;padding-right:2px;width:30px;height:30px"/> <font color="black">'+msg+'</font>',
				overlayCSS: { 
					opacity: .2
				},
				css: { 
					'font-color':'#fff',
					width: '200px', 
					border: '1px solid #000', 
					padding: '5px', 
					backgroundColor: '#fff', 
					'-webkit-border-radius': '10px', 
					'-moz-border-radius': '10px', 
					opacity: 1, 
					color: '#fff' ,
					left: '44%',
					top: '36%'
					},
					baseZ:index});  
		
		
	};
	/**
	 * @手动关闭等待遮罩层
	 */
	laso.unblockUI=function(){
		$.unblockUI();
	};
	
	
	//*********************** 私有方法 ******************************//
	function Cmd(cmd, params) {
		this.cmd = cmd;
		this.params = params;
	}
	

})();


